package com.fdq.dianping.controller;


import com.fdq.dianping.entity.Result;
import com.fdq.dianping.service.IFollowService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author fdq
 * @since 2024-12-29
 */
@RestController
@RequestMapping("/follow")
public class FollowController {

    @Resource
    private IFollowService followService;

    //关注用户
    @PutMapping("/{id}/{isFollow}")
    public Result follow(@PathVariable("id") Long followUserId, @PathVariable("isFollow") Boolean isFollow){
        return followService.follow(followUserId,isFollow);
    }


    //判断是否已经关注了
    @GetMapping("/or/not/{id}")
    public Result isFollow(@PathVariable("id") Long followUserId){
        return followService.isFollow(followUserId);
    }


    //获取共同关注
    @GetMapping("/common/{id}")
    public Result commonFollowers(@PathVariable("id") Long followUserId){
        return followService.commonFollowers(followUserId);
    }

    //获取用户的粉丝
    @GetMapping("/getFans")
    public Result getFans(Long id){
        return followService.getFans(id);
    }

    //获取用户关注的人
    @GetMapping("/getFollows")
    public Result getFollows(Long id){
        return followService.getFollows(id);
    }

}
